package com.tencreat.service.mall.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.tencreat.common.constant.TencreatIdAndName;
import com.tencreat.common.constant.TencreatMapData;
import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.common.enums.mall.JumpTypeEnum;
import com.tencreat.common.exception.CustomException;
import com.tencreat.common.utils.StringUtils;
import com.tencreat.domain.account.MallStore;
import com.tencreat.domain.mall.MallGoods;
import com.tencreat.domain.mall.MallLunbo;
import com.tencreat.domain.mall.MallStorage;
import com.tencreat.domain.mall.MallStoreSetmeal;
import com.tencreat.domain.mall.dto.AdminLunboAddEditDTO;
import com.tencreat.domain.mall.vo.AdminLunboVO;
import com.tencreat.domain.mall.vo.MallGoodsListVO;
import com.tencreat.domain.mall.vo.MallLunboVO;
import com.tencreat.domain.mall.vo.ResJumpRecordVO;
import com.tencreat.mapper.mall.MallLunboMapper;
import com.tencreat.mapper.mall.MallStoreSetmealMapper;
import com.tencreat.service.account.IMallStoreService;
import com.tencreat.service.account.IMallSystemService;
import com.tencreat.service.mall.IMallGoodsService;
import com.tencreat.service.mall.IMallLunboService;
import com.tencreat.service.mall.IMallStoreSetmealService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 套餐分类 Service业务层处理
 *
 * @author tencreat
 * @date 2021-09-15
 */
@Service
public class MallStoreSetmealServiceImpl extends ServiceImpl<MallStoreSetmealMapper, MallStoreSetmeal> implements IMallStoreSetmealService {

    @Autowired
    private IMallStoreService mallStoreService;

    @Autowired
    private IMallGoodsService mallGoodsService;

    @Override
    public boolean add(MallStoreSetmeal mallStoreSetmeal) {
        MallStore mallStore = mallStoreService.lambdaQuery().eq(MallStore::getUserId, mallStoreSetmeal.getUserId()).one();
        if (mallStore==null){
            throw new CustomException("找不到相关店铺！");
        }
        baseMapper.insert(mallStoreSetmeal);
        return true;
    }

    @Override
    public List<MallStoreSetmeal> selectList(QueryWrapper<MallStoreSetmeal> wrapper) {
        return baseMapper.selectList(wrapper);
    }

    @Override
    public IPage<MallStoreSetmeal> page(IPage<MallStoreSetmeal> page, MallStoreSetmeal mallStoreSetmeal) {

//        IPage<MallStoreSetmeal> page1 = baseMapper.page(page, mallStoreSetmeal);



//        return page.convert(item -> {
//            MallGoodsListVO mallGoodsListVO = new MallGoodsListVO();
//
//
//            return mallGoodsListVO;
//        });



        return baseMapper.page(page,mallStoreSetmeal);
    }
}



